﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace PRO_DOCS.BLL.WIN.SystemSettings
{
    public class SystemSettings : Templates.MasterAppClas
    {
        public DAL.Database.APPLICATION_EMAIL_SETTING SYSTEM_APPLICATION_EMAIL_SETTING
        {
            get
            {
                return (from email_settings in PRO_DOCSDatabaseDataContext.APPLICATION_EMAIL_SETTINGs
                        select email_settings).FirstOrDefault();
            }
        }

        public DAL.Database.APPLICATION_WORKFLOW_SETTING SYSTEM_APPLICATION_WORKFLOW_SETTING
        {
            get
            {
                return (from wf_settings in PRO_DOCSDatabaseDataContext.APPLICATION_WORKFLOW_SETTINGs
                        select wf_settings).FirstOrDefault();
            }
        }

        public List<string> APPLICATION_WORKFLOW_SAVING_FOLDERS
        {
            get
            {
                List<string> CURRENT_ARCHIVES_COPYING_FOLDERS = new List<string>();
                List<PRO_DOCS.DAL.Database.ARCHIVE_DEPARTMENTS_STORAGES_HEIRARCHY_PHYSICAL_PATHE> aRCHIVE_DEPARTMENTS_STORAGES_HEIRARCHY_PHYSICAL_PATHES = SYSTEM_APPLICATION_WORKFLOW_SETTING.ARCHIVE_DEPARTMENTS_STORAGES_HEIRARCHy.ARCHIVE_DEPARTMENTS_STORAGES_HEIRARCHY_PHYSICAL_PATHEs.ToList();

                for (int i = 0; i < aRCHIVE_DEPARTMENTS_STORAGES_HEIRARCHY_PHYSICAL_PATHES.Count; i++)
                {
                    if (new DirectoryInfo(aRCHIVE_DEPARTMENTS_STORAGES_HEIRARCHY_PHYSICAL_PATHES[i].ARCHIVE_DEPARTMENTS_STORAGES_HEIRARCHY_PHYSICAL_PATH).Exists)
                    {
                        CURRENT_ARCHIVES_COPYING_FOLDERS.Add(aRCHIVE_DEPARTMENTS_STORAGES_HEIRARCHY_PHYSICAL_PATHES[i].ARCHIVE_DEPARTMENTS_STORAGES_HEIRARCHY_PHYSICAL_PATH);
                    }
                }

                return CURRENT_ARCHIVES_COPYING_FOLDERS;
            }
        }


        public List<string> APPLICATION_EMAILS_SAVING_FOLDERS
        {
            get
            {
                List<string> CURRENT_ARCHIVES_COPYING_FOLDERS = new List<string>();
                List<PRO_DOCS.DAL.Database.ARCHIVE_DEPARTMENTS_STORAGES_HEIRARCHY_PHYSICAL_PATHE> aRCHIVE_DEPARTMENTS_STORAGES_HEIRARCHY_PHYSICAL_PATHES = SYSTEM_APPLICATION_EMAIL_SETTING.ARCHIVE_DEPARTMENTS_STORAGES_HEIRARCHy.ARCHIVE_DEPARTMENTS_STORAGES_HEIRARCHY_PHYSICAL_PATHEs.ToList();

                for (int i = 0; i < aRCHIVE_DEPARTMENTS_STORAGES_HEIRARCHY_PHYSICAL_PATHES.Count; i++)
                {
                    if (new DirectoryInfo(aRCHIVE_DEPARTMENTS_STORAGES_HEIRARCHY_PHYSICAL_PATHES[i].ARCHIVE_DEPARTMENTS_STORAGES_HEIRARCHY_PHYSICAL_PATH).Exists)
                    {
                        CURRENT_ARCHIVES_COPYING_FOLDERS.Add(aRCHIVE_DEPARTMENTS_STORAGES_HEIRARCHY_PHYSICAL_PATHES[i].ARCHIVE_DEPARTMENTS_STORAGES_HEIRARCHY_PHYSICAL_PATH);
                    }
                }

                return CURRENT_ARCHIVES_COPYING_FOLDERS;
            }
        }
    }
}
